#ifndef _KOZOS_H_INCLUDED_
#define _KOZOS_H_INCLUDED_

#include "defines.h"
#include "syscall.h"

kz_thread_id_t kz_run(kz_func_t func, char *name, int priority,
                        unsigned stacksize, int argc, char *argv[]);
void kz_exit(void);
int kz_wait(uint32 tick);
int kz_sleep(void);
int kz_wakeup(kz_thread_id_t id);
kz_thread_id_t kz_getid(void);
int kz_chpri(int priority);
void *kz_kmalloc(int size);
int kz_kmfree(void *p);
int kz_send(kz_msgbox_id_t id, int size, char *p, int priority, int maxnum);
kz_thread_id_t kz_recv(kz_msgbox_id_t id, int *sizep, char **pp);
kz_thread_id_t kz_recva(kz_msgbox_id_t id, int *sizep, char **pp, uint32 tick);
kz_thread_id_t kz_recvi(kz_msgbox_id_t id, int *sizep, char **pp);
int kz_setintr(softvec_type_t type, kz_handler_t handler);
int kz_resetintr(softvec_type_t type);
kz_msgbox_id_t kz_getmsgbox(void);
int kz_freemsgbox(kz_msgbox_id_t id);
char *kz_getthreads();
char *kz_resource();
uint32 kz_systime();

void kz_start(kz_func_t func, char *name, int priority, unsigned stacksize, int argc, char *argv[]);
void kz_sysdown(const char *message);
void kz_reset(void);

#ifdef NOASSERT
#define ASSERT(cond, msg)
#else
#define ASSERT(cond, msg)  do { if (!(cond)) kz_sysdown(msg); } while (0)
#endif

#endif
